﻿package com.sgcc.nfc.lock.data.remote.dto.region

import com.google.gson.annotations.SerializedName
import com.sgcc.nfc.lock.domain.model.Region

data class RegionDto(
    @SerializedName("regionId") val regionId: Long?,
    @SerializedName("regionName") val regionName: String?,
    @SerializedName("parentId") val parentId: Long?,
    @SerializedName("level") val level: Int?,
    @SerializedName("regionType") val regionType: Int?,
    @SerializedName("levelPath") val levelPath: String?,
    @SerializedName("children") val children: List<RegionDto>?
) {
    fun toDomain(): Region = Region(
        regionId = regionId ?: 0L,
        regionName = regionName.orEmpty(),
        parentId = parentId,
        level = level,
        regionType = regionType,
        levelPath = levelPath,
        children = children?.map(RegionDto::toDomain).orEmpty()
    )
}
